<template>
 <div class="detail">
    <div class="shop-head" :style="{ backgroundImage: `url(${ shopinfo.info && shopinfo.info.poi_back_pic_url})`}">
      <img class="logo" :src="shopinfo.info && shopinfo.info.picUrl" alt="">
      <span class="name">{{shopinfo.info && shopinfo.info.name}}</span>
    </div>
    <!-- 分类及商品列表 -->
    <div class="box">
      <div class="left">
        <!-- 分类列表 -->
        <div @click="currentIndex = index" class="cate" v-for="(item,index) in shopinfo.taglist" :key="index">{{item.name}}</div>
      </div>
      <div class="right">
        <!-- 商品列表 -->
        <div class="good" v-for="(item,index) in shopinfo.taglist && shopinfo.taglist[currentIndex].goodlist" :key="index">
          <div class="img-box">
            <img :src="item.picture" alt="">
          </div>
          <div class="text">
            <div class="name">{{item.name}}</div>
            <div class="price">{{item.min_price}}</div>
          </div>
        </div>
      </div>
    </div>
  </div> 
</template>

<script>
import {shop_shopinfo} from '../api'
export default {
    data(){
    return {
      currentIndex:0,//用来保存分类下标
      shopinfo:{}
    }
  },
  mounted(){
    shop_shopinfo({id: this.$route.params.id }).then((res)=>{
      if( res.data.code == 200 ){
        console.log(res.data.shopinfo);
        this.shopinfo = res.data.shopinfo;
      }else{
        alert(res.data.msg);
        this.$router.go(-1);
      }
    })
  }
}
</script>

<style scoped>
  .shop-head{
  background-size: cover;
  display: flex;
  align-items: center;
  padding: 50px 20px;
}
.shop-head img{
  width: 40px;
  height: 40px;
  border-radius: 50%;
  margin-right: 10px;
}
.shop-head .name{
  color: white;
  font-size: 18px;
}
.box {
  display: flex;
}
.box .left{
  width: 120px;
  line-height: 40px;
}
.box .right .good{
  display: flex;
}
.box .right .img-box{
  width: 100px;
  margin-right: 10px;
}
.box .right .img-box img{
  width: 100%;
}
.box .right .text{
  flex:1;
}
</style>